<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$id = $_GPC['id'];
$op = $_GPC['op'];
$openid = $_GPC['openid'];
$uniacid = $_W['uniacid'];
if ($op == 'list' || empty($op)) {
	if ($_W['ispost'] && $op == 'list') {
		$nowpage = $_GPC['limit'];
		$pindex = max(1, intval($nowpage));
		$psize = 10;
		$list = pdo_fetchall('SELECT * FROM ' . tablename($this->tablefav) . ' WHERE uniacid = :uniacid AND openid = :openid ORDER BY `ctime` DESC,`id` DESC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize, array(':uniacid' => $uniacid, ':openid' => $openid));
		if (!empty($keyword) && empty($list)) {
			exit(json_encode(array('status' => 301, 'content' => $list)));
		}
		if (!empty($list)) {
			foreach ($list as $key => $value) {
				$list[$key]['itemfee3'] = intval($list[$key]['itemfee3']);
				$favitem = pdo_fetch('SELECT * FROM ' . tablename($this->tableitemall) . ' WHERE status=1 and uniacid = :uniacid AND id = :id', array(':uniacid' => $uniacid, ':id' => $value['itemid']));
				if ($favitem) {
					$list[$key]['url'] = $this->createMobileUrl('show_all', array('id' => $favitem['id'], 'op' => 'share'));
					$list[$key]['yhjurl'] = $this->createMobileUrl('show_all', array('id' => $favitem['id'], 'op' => 'yhj'));
				} else {
					$list[$key]['url'] = "#";
					$list[$key]['yhjurl'] = "#";
					pdo_delete($this->tablefav, array('id' => $list[$key]['id']));
				}
			}
			$sta = 200;
		} else {
			$sta = -103;
		}
		exit(json_encode(array('status' => $sta, 'content' => $list)));
	}
}